<template>
  <el-drawer v-model="drawer" :before-close="handleClose" size="70%" modal-class="pay-drawer">
    <template #header>
      <title-view title="发包付款计划" />
    </template>
    <div v-if="payList.length > 0">
      <div>
        发包金额：<span style="color: #ea0000">¥{{ factMoney }}</span>
      </div>
      <el-table
        stripe
        :data="payList"
        style="width: 100%; margin-top: 20px"
        :header-cell-style="{ background: '#F2F6FC', color: '#4E5969', 'font-weight': 400, 'font-size': '14px' }"
      >
        <el-table-column prop="nodeName" label="付款节点" />
        <el-table-column prop="constructionNodeName" label="施工节点" />
        <el-table-column prop="acceptanceItem" label="验收项" />
        <el-table-column prop="originalPlainStartDate" label="预计开工时间" />
        <el-table-column label="计算规则">
          <template #default="{ row }">
            {{ row.computeRule === 1 ? "发包总金额*付款比例" : "工种发包总价*付款比例" }}
          </template>
        </el-table-column>
        <el-table-column label="计划付款比例">
          <template #default="{ row }"> {{ row.payRate }}%</template>
        </el-table-column>
        <el-table-column prop="paymentAmount" label="计划付款金额" />
      </el-table>
    </div>
    <el-empty v-else description="暂无内容" style="padding-top: 160px" />
  </el-drawer>
</template>
<script setup>
import { ref } from "vue";
import { paymentList } from "@/apis/contracting";

const factMoney = ref();
const payList = ref([]);
const drawer = ref(false);
const contracteesId = ref("");
// 关闭
const handleClose = () => {
  drawer.value = false;
};
const openDrawer = async row => {
  contracteesId.value = row.contracteesId;
  factMoney.value = row.factMoney;
  await getList();
  drawer.value = true;
};
const getList = async () => {
  const { data } = await paymentList(contracteesId.value);
  payList.value = data || [];
};
defineExpose({ openDrawer });
</script>
<style scoped lang="scss"></style>
